<template>
	<div>
		<div>
			<el-row :span="24" style="margin:26px 0 0;">
				<el-form :inline="true" :model="formInline" class="demo-form-inline" label-width="100px">
					<el-form-item label="提现状态">
						<el-select v-model="formInline.status" style="width: 150px;">
							<el-option label="全部" value=""></el-option>
							<el-option label="处理中" value="P"></el-option>
							<el-option label="成功" value="TRANSFER_SUCCESS"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="商户名字">
						<el-input v-model="formInline.storeName"></el-input>
					</el-form-item>
					<el-form-item label="商户ID">
						<el-input v-model="formInline.storeId"></el-input>
					</el-form-item>
					<el-form-item label="时间:">
						<el-date-picker type="date" placeholder="开始时间" v-model="startTime" style="width:180px;"></el-date-picker>
						到
						<el-date-picker type="date" placeholder="结束时间" v-model="endTime" style="width:180px;"></el-date-picker>
					</el-form-item>
					<el-button type="primary" @click="fetchData(1)">查询</el-button>
				</el-form>
			</el-row>

			<el-table :data="pageInfo.dtos" v-loading="table_loading" element-table_loading-text="加载中" stripe style="width: 100%">
				<el-table-column label="平台订单号" width="150" prop='outTradeNo'>
				</el-table-column>

				<el-table-column width="150" label="出款账号" prop='payerIdentity'>
				</el-table-column>
				<el-table-column width="150" label="入款账号" prop='payeeIdentity'>
				</el-table-column>
				<el-table-column label="用户ID" width="150">
					<template scope="scope">
						<router-link :to="'/user/user_detail/'+scope.row.userId" target="_blank"><span class="pointer">{{ scope.row.userId}}</span></router-link>
					</template>
				</el-table-column>
				<el-table-column width="200" label="银行卡名称" prop='cardName'>
				</el-table-column>
				<el-table-column width="200" label="开户人名称" prop='storeName'>
				</el-table-column>
				<el-table-column label="提现金额" width="100" prop='transferAmount'>
				</el-table-column>
				<!--        <el-table-column-->
				<!--          width="100"-->
				<!--          label="快捷通订单号"-->
				<!--          prop='tradeNo'>-->
				<!--        </el-table-column>-->
				<el-table-column width="150" label="提现时间" prop='orderTime'>
				</el-table-column>
				<el-table-column width="150" label="转账时间" prop='backTime'>
				</el-table-column>
				<!--  <el-table-column
          width="100"
          label="失败原因"
          prop='failReason'>
        </el-table-column> -->
				<!-- <el-table-column
          label="系统手续费"
          width="150"
          fixed="right"
          prop='transferSysAmount'>
        </el-table-column> -->

				<el-table-column width="100" label="转账状态">
					<template scope="scope">
						<span v-if="scope.row.status == 'P'">处理中</span>
						<span v-else-if="scope.row.status == 'F' || scope.row.status == 'TRANSFER_FAIL'">失败</span>
						<span v-else>成功</span>
					</template>
				</el-table-column>
				<el-table-column label="操作">
					<template scope="scope">
						<el-button v-if="scope.row.status == 'P'" type="primary" size="small" @click="confirmCash(scope.row)">完成转账
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div class="paginate">
				<el-pagination @current-change="handleCurrentChange" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize"
				 layout="total, prev, pager, next, jumper" :total="pageInfo.count">
				</el-pagination>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "cashList",
		data() {
			return {
				table_loading: true,
				formInline: {
					userId: '',
					pageNum: 1,
					pageSize: 10,
					storeId: '',
					status: '',
					orderTimeStart: '',
					ordreTimeEnd: '',
					storeName: ''
				},
				startTime: '',
				endTime: '',
				pageInfo: {
					pageNum: 1,
					pageSize: 10,
					count: 1,
					dtos: []
				},
				CashStat: {
					inAmt: 0,
					outAmt: 0,
					lastAmt: 0
				}
			}
		},
		mounted() {
			let vm = this
			if (vm.$route.query.id != undefined || vm.$route.query.id != null) {
				vm.formInline.storeId = vm.$route.query.id
			} else {
				vm.formInline.storeId = ''
			}
			vm.fetchData(1)
		},
		methods: {
			/**
			 * @Description: 获取提现记录列表
			 * @author liuChen
			 * @date 2020-09-08 13:07
			 */
			fetchData(page = 1) {
				let vm = this
				vm.table_loading = true
				if (vm.startTime && this.endTime) {
					vm.formInline.orderTimeStart = dateFormat(vm.startTime)
					vm.formInline.ordreTimeEnd = dateFormat(vm.endTime)
					if (vm.formInline.orderTimeStart > vm.formInline.ordreTimeEnd) {
						vm.$message({
							type: 'warning',
							message: '开始时间不能大于结束时间'
						});
						return;
					}
				} else {
					vm.formInline.orderTimeStart = ''
					vm.formInline.ordreTimeEnd = ''
				}
				// vm.table_loading = true
				vm.pageInfo.pageNum = page
				vm.formInline.pageNum = page
				vm.dataApi.ajax('storeWithdrawList', vm.formInline, res => {
					vm.table_loading = false
					let data = JSON.parse(JSON.stringify(res))
					vm.pageInfo.dtos = data.dtos
					vm.pageInfo.count = data.count
				});
			},
			handleCurrentChange(val) {
				this.fetchData(val);
			},
			confirmCash(row) {
				let vm = this
				let data = {
					outTradeNo: row.outTradeNo
				}
				vm.dataApi.ajax('storeOkWithraw', data, res => {
					vm.showMsg('完成成功')
					vm.fetchData(1)
				});
			}
		}
	}
</script>

<style scoped>

</style>
